﻿/* 错误码定义规范
 * 1.错误码以大写字母E加9位数字组成，如：[ErrorDescription("")]
        E000000001
 * 2.错误码的9位数字按3位一组分为3组。从左到右，第一组代表系统编号，第二组代表接口编号，第三组代表具体错误编号
 * 3.其中E000000开头是系统预留作为特殊用途的编号，如[ErrorDescription("")]
        E000000001是未知的错误。具体见以下枚举定义
 */

using System;

namespace TrinityAPI.Base.Models
{
    public class ErrorDescriptionAttribute : Attribute
    {
        private string message;
        public string Message
        {
            get { return message; }
        }
        public ErrorDescriptionAttribute(string msg = null)
        {
            message = msg;
        }
    }

    public enum ErrorCode
    {
        /// <summary>
        /// 未知错误
        /// </summary>
        [ErrorDescription("Unknown error")]
        E000000001,
        /// <summary>
        /// 配置错误
        /// </summary>
        [ErrorDescription("The api config is invalid ({0})")]
        E000000002,
        /// <summary>
        /// 不支持的Cache类型错误
        /// </summary>
        [ErrorDescription("he cache type of {0} is not support")]
        E000000003,
        /// <summary>
        /// 不支持的数据库类型错误
        /// </summary>
        [ErrorDescription("The database type of {0} is not support")]
        E000000004,
        /// <summary>
        /// 数据库操作错误
        /// </summary>
        [ErrorDescription("Database fail to execute sql which type is [{0}]")]
        E000000005,
        /// <summary>
        /// 参数对象的字段太多导致转换成数据库表失败
        /// </summary>
        [ErrorDescription("The value of {0} convert to database table failed due to too many fields")]
        E000000006,
        /// <summary>
        /// 无效JS函数
        /// </summary>
        [ErrorDescription("The javascript function [{0}] is invalid")]
        E000000007,
        /// <summary>
        /// 循环引用API配置
        /// </summary>
        [ErrorDescription("[{0}] is referred to in a loop")]
        E000000008,
        /// <summary>
        /// 引用无效的API配置
        /// </summary>
        [ErrorDescription("The reference [{0}] is invalid")]
        E000000009,
        /// <summary>
        /// 验证错误
        /// </summary>
        [ErrorDescription("Illegal request")]
        E000000010,
        /// <summary>
        /// 外部API无效的返回参数
        /// </summary>
        [ErrorDescription("Unknown api response:{0}")]
        E000000011,
        /// <summary>
        /// 外部API无效的错误码
        /// </summary>
        [ErrorDescription("Unknown api response code:{0}")]
        E000000012,
        /// <summary>
        /// 外部API协议错误
        /// </summary>
        [ErrorDescription("API protocal error:{0}-{1}")]
        E000000013,
        /// <summary>
        /// 外部API请求超时
        /// </summary>
        [ErrorDescription("API request timeout")]
        E000000014,
        /// <summary>
        /// 外部API无法连接
        /// </summary>
        [ErrorDescription("API connect failure")]
        E000000015,
        /// <summary>
        /// 外部API参数无法转换成XML
        /// </summary>
        [ErrorDescription("API parameters fail to parse to xml:{0}")]
        E000000016,
        /// <summary>
        /// 非空参数错误
        /// </summary>
        [ErrorDescription("The value of {0} can not be null or empty")]
        E000000021,
        /// <summary>
        /// 参数数据类型错误
        /// </summary>
        [ErrorDescription("The data type of {0} must be {1}")]
        E000000022,
        /// <summary>
        /// 数组参数的元素数量小于指定值
        /// </summary>
        [ErrorDescription("Quantity of the items in {0} can not less than {1}")]
        E000000023,
        /// <summary>
        /// 数组参数的元素数量大于指定值
        /// </summary>
        [ErrorDescription("Quantity of the items in {0} can not greater than {1}")]
        E000000024,
        /// <summary>
        /// 字符串参数的长度小于指定值
        /// </summary>
        [ErrorDescription("The length of {0} can not less than {1}")]
        E000000025,
        /// <summary>
        /// 字符串参数的长度大于指定值
        /// </summary>
        [ErrorDescription("The length of {0} can not greater than {1}")]
        E000000026,
        /// <summary>
        /// 数字/时间参数的大小小于指定值
        /// </summary>
        [ErrorDescription("The value of {0} can not less than {1}")]
        E000000027,
        /// <summary>
        /// 数字/时间参数的大小大于指定值
        /// </summary>
        [ErrorDescription("The value of {0} can not greater than {1}")]
        E000000028,
        /// <summary>
        /// 参数值不在指定的有效值范围内
        /// </summary>
        [ErrorDescription("The value of {0} must be in the range of [{1}]")]
        E000000029
    }
}
